Text=The Wise 6.0 sample script shows how to do a simple division function with Wise's expression parser.
end
item: Remark
end
item: Remark
Text=These middle lines of code are devoted to getting the numbers to be divided,
end
item: Remark
Text= and to make sure that the divisor is not zero.
end
item: Remark
end
item: Set Variable
Variable=NUMBER2
Value=0
end
item: Prompt for Text
Window Title=Parser Division Test
Prompt Title=Please enter a number.
Variable=NUMBER
end
item: If/While Statement
Variable=NUMBER2
Value=0
Flags=00010000
end
item: Prompt for Text
Window Title=Parser Divisor Test
Prompt Title=Please enter a second number.
Variable=NUMBER2
end
item: If/While Statement
Variable=NUMBER2
Value=0
end
item: Display Message
Title=Invalid Number
Text=You can not divide a number by zero. It will cause your application to crash.
end
item: End Block
end
item: End Block
end
item: Remark
end
item: Remark
Text=There are two ways to use the expression parser. The first is with a set variable command, using the "Evaluate expression" option.
end
item: Remark
Text=When creating an expression, you do not have to use the percent signs to define the variables.
end
item: Set Variable
Variable=ANSWER
Value=NUMBER / NUMBER2
Flags=00100000
end
item: Display Message
Title=Expression Parser - Division Test 1.
Text=This Display message shows the set variable command in conjunction with the Expression parser.
Text=
Text= %Number% / %Number2% = %Answer%
Text=
Text=(Note: When dividing, the parser will always return an integer value, rounded down. ex. 10/3 = 3. 10/4 = 2.)
end
item: Remark
end
item: Remark
Text=This is the second way, using an If statement, and the "Expression true" option.
end
item: Remark
Text=You can also use the command options such as <, >, >=, <=, and, or, not, and <>.
end
item: If/While Statement
Value=ANSWER = NUMBER / NUMBER2
Flags=00001101
end
item: Display Message
Title=Expression Parser - Division Test 2.
Text=This Display message shows the If Statement in conjunction with the Expression parser. If the result was not true, this message would not be displayed.
Text=
Text=Yes, %Number% / %Number2% = %Answer%
Text=
Text=(Note: When dividing, the parser will always return an integer value rounded down. ex. 10/3 = 3. 10/4 = 2.)